package com.shiroha.video.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import com.mybatisflex.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum WorkType {
    VIDEO(0, "视频"),
    PICTURE(1, "图片");

    @EnumValue
    @JsonValue
    private final int value;
    private final String description;

    WorkType(int value, String description) {
        this.value = value;
        this.description = description;
    }

    /**
     * 根据 value 获取对应的枚举值。
     *
     * @param value 枚举值的 value。
     * @return 对应的枚举值。
     * @throws IllegalArgumentException 如果 value 无效。
     */
    public static WorkType fromValue(int value) {
        for (WorkType type : WorkType.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid WorkType value: " + value);
    }
}
